﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SitePropertiesEditor.aspx.cs"
    Inherits="Trentacular.SharePoint.Layouts.SitePropertiesEditor"
    DynamicMasterPageFile="~masterurl/default.master" %>

<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register Tagprefix="sp" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Register TagPrefix="t" Namespace="Trentacular.SharePoint.Web.UI.WebControls" Assembly="Trentacular.SharePoint, Version=1.0.0.0, Culture=neutral, PublicKeyToken=544f3330e04bd2bc" %>
<%@ Register TagPrefix="wssuc" TagName="InputFormSection" src="~/_controltemplates/InputFormSection.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="InputFormControl" src="~/_controltemplates/InputFormControl.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="ButtonSection" src="~/_controltemplates/ButtonSection.ascx" %>

<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
    <asp:UpdatePanel runat="server">
        <ContentTemplate>
            <table border="0" cellspacing="0" cellpadding="0" width="100%">
        	    <wssuc:InputFormSection
        		     Title="Add New Property"
        		     runat="server">
        		     <Template_Description>
            			 It is preferred to use all lowercase key names to seemlessly support the retrofitted AllProperties Hashtable.
            			 If uppercase letters are used, the property will be added separately to both the the classic Properties PropertyBag (which is
            			 not case sensitive) and the newer AllProperties Hashtable in order to support case sensitivity.
        		     </Template_Description>
        		     <Template_InputFormControls>
        		        <wssuc:InputFormControl runat="server" LabelText="Key">
        				    <Template_Control>
        					    <sp:InputFormTextBox ID="txtKey" runat="server" Title="Key"
        					        class="ms-long" /><sp:InputFormRequiredFieldValidator runat="server"
        					        ControlToValidate="txtKey"
        					        ValidationGroup="AddProperty"
        						    ErrorMessage="Key is required" />
        				    </Template_Control>
        			    </wssuc:InputFormControl>
        		        <wssuc:InputFormControl runat="server" LabelText="Value">
        				    <Template_Control>
        					    <sp:InputFormTextBox ID="txtValue" runat="server" Title="Value"
        					        class="ms-long" /><sp:InputFormRequiredFieldValidator runat="server"
        					        ControlToValidate="txtValue"
        						    ValidationGroup="AddProperty"
        						    ErrorMessage="Value is required" />
        				    </Template_Control>
        			    </wssuc:InputFormControl>
        		     </Template_InputFormControls>
        	     </wssuc:InputFormSection>
        	     <wssuc:ButtonSection runat="server" ShowStandardCancelButton="false">
        		    <Template_Buttons>
        			    <asp:Button runat="server" class="ms-ButtonHeightWidth"
        			        OnClick="btnAdd_Click" Text="Add" ValidationGroup="AddProperty" />
        		    </Template_Buttons>
        	    </wssuc:ButtonSection>
            </table>

            <t:DelegateDataSource ID="dsProperties" runat="server"
                AutoSort="true"
                OnSelect="GetProperties"
                OnUpdate="UpdateProperty"
                OnDelete="DeleteProperty" />

            <h3 class="ms-standardheader">Site Properties</h3>
        	<sp:SPGridView ID="gvProperties" runat="server" width="100%" DataSourceId="dsProperties" AutoGenerateColumns="false" DataKeyNames="Key" AllowSorting="true">
        		<AlternatingRowStyle CssClass="ms-alternating" />
        		<Columns>
        			<asp:BoundField HeaderText="Key" DataField="Key" SortExpression="Key" ReadOnly="true" />
        			<asp:TemplateField HeaderText="Value">
        			    <ItemTemplate><%# Server.HtmlEncode(Eval("Value").ToString()) %></ItemTemplate>
        			    <EditItemTemplate>
        			        <asp:TextBox ID="txtUpdateValue" runat="server" CssClass="ms-long"
        			            Text='<%# Bind("Value") %>' />
        			        <asp:LinkButton runat="server" CommandName="Update" Text="Update" />
        			        <asp:LinkButton runat="server" CommandName="Cancel" Text="Cancel" CausesValidation="false" />
        			        <sp:InputFormRequiredFieldValidator runat="server"
        				        ControlToValidate="txtUpdateValue"
        					    ErrorMessage="Value is required" />
        			    </EditItemTemplate>
        			</asp:TemplateField>
        			<asp:ButtonField HeaderText="Edit" CommandName="Edit"
        			    ButtonType="Image" ImageUrl="/_layouts/images/edit.gif" Text="Edit" />
        			<asp:ButtonField HeaderText="Delete" CommandName="Delete"
        			    ButtonType="Image" ImageUrl="/_layouts/images/delete.gif" Text="Delete" />
        		</Columns>
        	</sp:SPGridView>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>

<asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">
Manage Site Properties
</asp:Content>

<asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server" >
Manage Site Properties
</asp:Content>

<asp:content contentplaceholderid="PlaceHolderPageDescription" runat="server">
Use this page to manage properties stored in thisd Site's property bag
</asp:content>
